package com.yao.ro.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 商品类型枚举
 * 
 * @author yaoyuming
 * @date 2020/04/08 13:57
 */
@Getter
public enum GoodsTypeEnum {
    RQU(1, "装备"), DR(2, "图纸"), CON(3, "消耗品"), MAT(4, "制作材料");

    private static Map<Integer, String> enums =
        Stream.of(GoodsTypeEnum.values()).collect(Collectors.toMap(GoodsTypeEnum::getCode, GoodsTypeEnum::getDesc));

    @EnumValue
    private final int code;
    @JsonValue
    private final String desc;

    GoodsTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDesc(int code) {
        return enums.get(code);
    }
}
